A loaded module is automatically unloaded following a delay after the last close of a device it supports. The delay is configurable using systune, as the module_unld_delay variable (see the systune(1) reference page). You can use ml to specify an unloading delay for a particular module.
The lboot or ml command can be used to unload a module before the delay expires, or when the N flag prevents automatic unloading.
Just before unloading, the kernel invokes the driver's pfxunload() entry point. Then the module is removed from memory, and returned to registered status. It is up to the pfxunload() entry point to decide whether unloading can be permitted. Experience has shown that most of the problems with loadable drivers arise from unloading and reloading. The precautions to take are described under "Entry Point unload()".